<?php
// @formatter:off
/**
 * @file s.edittags.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-06-16 23:56:49 +0000 (Sun, 16 Jun 2013) $
 *
 * $Id: s.edittags.php 73 2013-06-16 23:56:49Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA1/themes/default/controlers/simplecontainer/s.edittags.php $
 */
// @formatter:on

global $wcGroupForbidden;
global $wcComic;
global $wcDirectory;
global $wcTag;
global $wcThemeAssigns;

if(defined("__SIMPLE_CONTAINER__") && !$wcGroupForbidden && $wcProfile->allowedAny(WC_PERM_COMIC_SET_TAG, WC_PERM_DIRECTORY_SET_TAG, WC_PERM_TAG_SET_TAG)) {
	$wcThemeAssigns["ACTIONCONTENT"] = "/simplecontainer/s.edittags.html";
	$wcThemeAssigns["ACTIONPRESCRIPT"] = "/simplecontainer/s.edittags.js";

	if($wcComic && $wcProfile->granted(WC_PERM_COMIC_SET_TAG)) {
		$wcThemeAssigns["EDIT-WHAT"] = "comic";
		$wcThemeAssigns["EDIT-NAME"] = $wcComic->name;
		$wcThemeAssigns["EDIT-ID"] = $wcComic->id;
		$wcThemeAssigns["EDIT-URI-NAME"] = "comic";
		$wcThemeAssigns["EDIT-PREVIEWS"] = array($wcComic->previewUri());
	} elseif($wcDirectory && $wcProfile->granted(WC_PERM_DIRECTORY_SET_TAG)) {
		$wcThemeAssigns["EDIT-WHAT"] = "directory";
		$wcThemeAssigns["EDIT-NAME"] = $wcDirectory->name;
		$wcThemeAssigns["EDIT-ID"] = $wcDirectory->id;
		$wcThemeAssigns["EDIT-URI-NAME"] = "directory";
		$wcThemeAssigns["EDIT-PREVIEWS"] = $wcDirectory->previews();
	} elseif($wcTag && $wcProfile->granted(WC_PERM_TAG_SET_TAG)) {
		$wcThemeAssigns["EDIT-WHAT"] = "tag";
		$wcThemeAssigns["EDIT-NAME"] = $wcTag->name;
		$wcThemeAssigns["EDIT-ID"] = $wcTag->id;
		$wcThemeAssigns["EDIT-URI-NAME"] = "tag";
		$wcThemeAssigns["EDIT-PREVIEWS"] = $wcTag->previews();
	} else {
		$wcThemeAssigns["error-string"] = "This item is not available for tags edition";
		require "{$this->_themeRoot}/controlers/contents/c.500.php";
	}
} else {
	$wcThemeAssigns["error-string"] = "You're not allowed to edit item's tags";
	require "{$this->_themeRoot}/controlers/contents/c.403.php";
}
?>